const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property
    angle:number=0.0

    @property
    velocity:number=0.0

    @property(cc.Node)
    limit:cc.Node=null

    start () {
        this.angle=Math.random()*Math.PI*2;   
    }

    update (dt) {
        let a=this.angle;
        let x=Math.cos(a);
        let y=Math.sin(a);
        let s=cc.v3(x,y).mul(this.velocity*dt).add(this.node.position);
        this.node.position=cc.v3(s,0);
        let pos=this.node.position;
        

        if(this.limit&&!this.limit.getBoundingBox().contains(cc.v2(pos))){
            this.node.removeFromParent();
            cc.log("is remove!!");
        }
    }
}
